<!DOCTYPE html>
<html>
<head>
<title>佣金管理</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>佣金管理</h5>
            </div>
            <form id="listForm" action="list" method="get">
                <div class="ibox-content">
                    <!-- 搜索 start -->
                    <div class="form-horizontal clear">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">标题：</label>
                            <div class="col-sm-2"><input class="form-control" type="text" name="title" value="#(title)"></div>
                        </div>
                        <div class="text-center">
                            <input type="submit" class="btn btn-primary btn-w-m" value="查 询">
                            <input type="reset" class="btn btn-primary btn-w-m" value="重 置">
                        </div>
                    </div>
                    <!-- 搜索 end -->
                    <!-- 列表 start -->
                    <div class="form-horizontal clear">
                        <div class="form-group">
                            <div class="col-sm-8">
                                <a href="javascript:;" class="btn btn-primary" id="refreshButton"><i class="fa fa-refresh"></i> 刷新</a>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered" id="listTable">
                                <thead>
                                    <tr>
                                        <th width="40" class="text-center"><input type="checkbox" id="selectAll" /></th>
                                        <th>ID</th>
                                        <th>会员</th>
                                        <th>订单编号</th>
                                        <th>商品标题</th>
                                        <th>商品实付金额</th>
                                        <th>佣金</th>
                                        <th>分销等级</th>
                                        <th>分销比例</th>
                                        <th>状态</th>
                                        <th>创建日期</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    #for(commission : page.list)
                                    <tr>
                                        <td class="text-center"><input type="checkbox" name="ids" value="#(commission.id)" /></td>
                                        <td>#(commission.id)</td>
                                        <td><img src="#(commission.member.avatar)" style="width:30px;height:30px;padding1px;border:1px solid #ccc">#(commission.member.nickname)</td>
                                        <td>#(commission.order.sn)</td>
                                        <td>#(commission.title)</td>
                                        <td>#(commission.amount)</td>
                                        <td>#(commission.distributeAmount)</td>
                                        <td>#if(commission.grade==1) 一级分销 #else if(commission.grade==2) 二级分销 #else if(commission.grade==3) 三级分销 #end</td>
                                        <td>#(commission.level)%</td>
                                        <td>#if(commission.status=="PENDING_SETTLEMENT") 待结算  #else if(commission.status=="PENDING_CHECK") 待审核 #else if(commission.status=="COMPLETED") 已完成 #else if(commission.status=="REJECTED") 已驳回 #end</td>
                                        <td>#(commission.createDate)</td>
                                        <td>
                                        	#if(commission.status=="PENDING_CHECK")
                                            <a href="javascript:;" class="check" val="#(commission.id)" status="COMPLETED">[通过]</a>
                                            <a href="javascript:;" class="check" val="#(commission.id)" status="REJECTED">[驳回]</a>
                                            #end
                                        </td>
                                    </tr>
                                    #end
                                </tbody>
                            </table>
                        </div>
                        <div class="text-center">
                            #pagination(pageNumber = page.pageNumber,totalPages = page.totalPage,pattern = "")
                                #include("../include/pagination.html")
                            #end
                        </div>
                    </div>
                    <!-- 列表 end -->
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

    var $check = $("#listTable a.check");
    
    //审核
    $check.click(function() {
        var $this = $(this);
        var status = $this.attr("status");
        if(confirm("您确定要"+(status=="COMPLETED"?"通过":"取消")+"吗？")){
             $.ajax({
                 url: "check",
                 type: "POST",
                 data: {id: $this.attr("val"),"status":status},
                 dataType: "json",
                 cache: false,
                 success: function(response) {
                 	if (response.type == "success") {
                         location.reload();
                     }else{
                         swal({title:'', text:response.msg,icon: 'error'});
                     }
                 }
             });
         }
        return false;
    });

});
</script>